﻿using System.Collections.Generic;
using System;
using System.Reflection;
using System.Runtime.Serialization;
using GraphMLComplexType;

namespace GraphInformation
{
    [DataContract]
    public class PairKeyValue
    {
        public PairKeyValue()
        {
        }

        public PairKeyValue(string key, string value)
        {
            m_Key = key;
            m_Value = value;
        }

        private String m_Key;
        [DataMember]
        public String Key
        {
            get { return m_Key; }
            set { m_Key = value; }
        }
        private String m_Value;
        [DataMember]
        public String Value
        {
            get { return m_Value; }
            set { m_Value = value; }
        }
    }

    [DataContract]
    public sealed class GraphElement
    {
        private List<PairKeyValue> m_keys;

        [DataMember]
        public List<PairKeyValue> Keys
        {
            get { return m_keys; }
            set { m_keys = value; }
        }
        private int m_id;

        public GraphElement()
        {
            m_keys = new List<PairKeyValue>();
            m_id = this.GetHashCode();
        }

        [DataMember]
        public int Id
        {
            get { return m_id; }
            set { 
                m_id = value;
            }
        }

        [DataMember]
        public double x;

        [DataMember]
        public double y;

        [DataMember]
        public double Width;

        [DataMember]
        public double Height;

        public override string ToString()
        {
            return Id.ToString();
        }
    }

    [DataContract]
    public class GraphEdge
    {
        private int m_source;
        

        private int m_target;
        
        public GraphEdge()
        { 
            
        }



        public GraphEdge(GraphElement source, GraphElement target)
        {
            m_source = source.Id;
            m_target = target.Id;
        }


        [DataMember]
        public int Source
        {
            get { return m_source; }
            set { m_source = value; }
        }

        [DataMember]
        public int Target
        {
            get { return m_target; }
            set { m_target = value; }
        }
    }

    [DataContract]
    public class Graph
    {
        private GraphElement[] m_Vertices;
        private GraphEdge[] m_Edges;

        [DataMember]
        public GraphEdge[] Edges
        {
            get { return m_Edges; }
            set { m_Edges = value; }
        }

        [DataMember]
        public GraphElement[]  Vertices
        {
            get { return m_Vertices; }
            set { m_Vertices = value; }
        }

        [DataMember]
        public double Width;

        [DataMember]
        public double Height;
    }
}